"""
Author: yopofeng
Date: 2021-03-19 18:22:06
LastEditTime: 2021-09-01 11:32:23
LastEditors: yopofeng
Description: test lib
"""
from os import name
import re


def retry(times):
    def wrapper(func):
        def exe(*args, **kwargs):
            n = 1
            while n < times:
                try:
                    print("ths %d time" % n)
                    return func(*args, **kwargs)
                except Exception as e:
                    print(e)
                    n += 1
            else:
                print("last time")
                return func(*args, **kwargs)

        return exe

    return wrapper

def real_wxml(wxml, remove_id=False):
    if remove_id:
        wxml = re.sub(r'\s*id="\S+"', "", wxml)
    else:
        wxml = re.sub(r'\s*id="(\S+--)\S+"', lambda m: m.group(0).replace(m.group(1), ""), wxml)
    wxml = re.sub(r'\s*class="((\S+--)[^\"]+)"', lambda m: m.group(0).replace(m.group(2), ""), wxml)
    return wxml

def myMap(test_class, case_prefix):
    names = []
    for key in dir(test_class):
        if key.startswith(case_prefix):
            names.append(key)
    return map(test_class, names)


def get_config(platform="devtools"):
    return None

# 全局变量, 测试case顺序执行
GlobalCnt = {
    "value": 0
}
